// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   ScatterChart.java

package org.achartengine.chart;

import android.graphics.*;
import org.achartengine.model.XYMultipleSeriesDataset;
import org.achartengine.renderer.*;

// Referenced classes of package org.achartengine.chart:
//			XYChart, PointStyle

public class ScatterChart extends XYChart
{

	public static final String TYPE = "Scatter";
	private static final float SIZE = 3F;
	private static final int SHAPE_WIDTH = 10;
	private float size;

	ScatterChart()
	{
		size = 3F;
	}

	public ScatterChart(XYMultipleSeriesDataset xymultipleseriesdataset, XYMultipleSeriesRenderer xymultipleseriesrenderer)
	{
		super(xymultipleseriesdataset, xymultipleseriesrenderer);
		size = 3F;
		size = xymultipleseriesrenderer.getPointSize();
	}

	protected void setDatasetRenderer(XYMultipleSeriesDataset xymultipleseriesdataset, XYMultipleSeriesRenderer xymultipleseriesrenderer)
	{
		super.setDatasetRenderer(xymultipleseriesdataset, xymultipleseriesrenderer);
		size = xymultipleseriesrenderer.getPointSize();
	}

	public void drawSeries(Canvas canvas, Paint paint, float af[], SimpleSeriesRenderer simpleseriesrenderer, float f, int i)
	{
		XYSeriesRenderer xyseriesrenderer = (XYSeriesRenderer)simpleseriesrenderer;
		paint.setColor(xyseriesrenderer.getColor());
		if (xyseriesrenderer.isFillPoints())
			paint.setStyle(android.graphics.Paint.Style.FILL);
		else
			paint.setStyle(android.graphics.Paint.Style.STROKE);
		int j = af.length;
		static class 1
		{

			static final int $SwitchMap$org$achartengine$chart$PointStyle[];

			static 
			{
				$SwitchMap$org$achartengine$chart$PointStyle = new int[PointStyle.values().length];
				try
				{
					$SwitchMap$org$achartengine$chart$PointStyle[PointStyle.X.ordinal()] = 1;
				}
				catch (NoSuchFieldError nosuchfielderror) { }
				try
				{
					$SwitchMap$org$achartengine$chart$PointStyle[PointStyle.CIRCLE.ordinal()] = 2;
				}
				catch (NoSuchFieldError nosuchfielderror1) { }
				try
				{
					$SwitchMap$org$achartengine$chart$PointStyle[PointStyle.TRIANGLE.ordinal()] = 3;
				}
				catch (NoSuchFieldError nosuchfielderror2) { }
				try
				{
					$SwitchMap$org$achartengine$chart$PointStyle[PointStyle.SQUARE.ordinal()] = 4;
				}
				catch (NoSuchFieldError nosuchfielderror3) { }
				try
				{
					$SwitchMap$org$achartengine$chart$PointStyle[PointStyle.DIAMOND.ordinal()] = 5;
				}
				catch (NoSuchFieldError nosuchfielderror4) { }
				try
				{
					$SwitchMap$org$achartengine$chart$PointStyle[PointStyle.POINT.ordinal()] = 6;
				}
				catch (NoSuchFieldError nosuchfielderror5) { }
			}
		}

		switch (1..SwitchMap.org.achartengine.chart.PointStyle[xyseriesrenderer.getPointStyle().ordinal()])
		{
		default:
			break;

		case 1: // '\001'
			for (int k = 0; k < j; k += 2)
				drawX(canvas, paint, af[k], af[k + 1]);

			break;

		case 2: // '\002'
			for (int l = 0; l < j; l += 2)
				drawCircle(canvas, paint, af[l], af[l + 1]);

			break;

		case 3: // '\003'
			float af1[] = new float[6];
			for (int i1 = 0; i1 < j; i1 += 2)
				drawTriangle(canvas, paint, af1, af[i1], af[i1 + 1]);

			break;

		case 4: // '\004'
			for (int j1 = 0; j1 < j; j1 += 2)
				drawSquare(canvas, paint, af[j1], af[j1 + 1]);

			break;

		case 5: // '\005'
			float af2[] = new float[8];
			for (int k1 = 0; k1 < j; k1 += 2)
				drawDiamond(canvas, paint, af2, af[k1], af[k1 + 1]);

			break;

		case 6: // '\006'
			canvas.drawPoints(af, paint);
			break;
		}
	}

	protected RectF[] clickableAreasForPoints(float af[], float f, int i)
	{
		int j = af.length;
		RectF arectf[] = new RectF[j / 2];
		for (int k = 0; k < j; k += 2)
		{
			int l = mRenderer.getSelectableBuffer();
			arectf[k / 2] = new RectF(af[k] - (float)l, af[k + 1] - (float)l, af[k] + (float)l, af[k + 1] + (float)l);
		}

		return arectf;
	}

	public int getLegendShapeWidth(int i)
	{
		return 10;
	}

	public void drawLegendShape(Canvas canvas, SimpleSeriesRenderer simpleseriesrenderer, float f, float f1, int i, Paint paint)
	{
		if (((XYSeriesRenderer)simpleseriesrenderer).isFillPoints())
			paint.setStyle(android.graphics.Paint.Style.FILL);
		else
			paint.setStyle(android.graphics.Paint.Style.STROKE);
		switch (1..SwitchMap.org.achartengine.chart.PointStyle[((XYSeriesRenderer)simpleseriesrenderer).getPointStyle().ordinal()])
		{
		case 1: // '\001'
			drawX(canvas, paint, f + 10F, f1);
			break;

		case 2: // '\002'
			drawCircle(canvas, paint, f + 10F, f1);
			break;

		case 3: // '\003'
			drawTriangle(canvas, paint, new float[6], f + 10F, f1);
			break;

		case 4: // '\004'
			drawSquare(canvas, paint, f + 10F, f1);
			break;

		case 5: // '\005'
			drawDiamond(canvas, paint, new float[8], f + 10F, f1);
			break;

		case 6: // '\006'
			canvas.drawPoint(f + 10F, f1, paint);
			break;
		}
	}

	private void drawX(Canvas canvas, Paint paint, float f, float f1)
	{
		canvas.drawLine(f - size, f1 - size, f + size, f1 + size, paint);
		canvas.drawLine(f + size, f1 - size, f - size, f1 + size, paint);
	}

	private void drawCircle(Canvas canvas, Paint paint, float f, float f1)
	{
		canvas.drawCircle(f, f1, size, paint);
	}

	private void drawTriangle(Canvas canvas, Paint paint, float af[], float f, float f1)
	{
		af[0] = f;
		af[1] = f1 - size - size / 2.0F;
		af[2] = f - size;
		af[3] = f1 + size;
		af[4] = f + size;
		af[5] = af[3];
		drawPath(canvas, af, paint, true);
	}

	private void drawSquare(Canvas canvas, Paint paint, float f, float f1)
	{
		canvas.drawRect(f - size, f1 - size, f + size, f1 + size, paint);
	}

	private void drawDiamond(Canvas canvas, Paint paint, float af[], float f, float f1)
	{
		af[0] = f;
		af[1] = f1 - size;
		af[2] = f - size;
		af[3] = f1;
		af[4] = f;
		af[5] = f1 + size;
		af[6] = f + size;
		af[7] = f1;
		drawPath(canvas, af, paint, true);
	}

	public String getChartType()
	{
		return "Scatter";
	}
}
